<?php


namespace svrlog;

use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Monolog\Processor\IntrospectionProcessor;
use Monolog\Processor\WebProcessor;
use Monolog\Processor\MemoryUsageProcessor;

class LogComponent
{
    public static function writeLog(){
        $date = date('Y-m-d');
        $dateFormat = "Y-m-d, H:i:s";
        $output = "[%datetime%] [%level_name%] %message% %context% %extra%\n";
        $formatter = new LineFormatter($output, $dateFormat);
        $stream = new StreamHandler('./' . $_SERVER['LOG_PATH'] . '/' . 'app-' . $date . '.log', \Monolog\Logger::DEBUG);
        $stream->setFormatter($formatter);
        $log = new Logger('book_import_svr');
        $log->pushHandler($stream);
        $log->pushProcessor(new IntrospectionProcessor());
        $log->pushProcessor(new WebProcessor());
        $log->pushProcessor(new MemoryUsageProcessor());
        return $log;
    }
}